@echo off

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                                                        ::
:: This files compiles the bootloader and kernel and then ::
:: it builds the floppy disk image and then packages the  ::
:: floppy image for distribution in a .ZIP file.          ::
::                                                        ::
::                                                        ::
:: February//04/2012                                      ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

set FASM=..\tools\fasm\fasm.exe
set BFI=..\tools\bfi\bfi.exe

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: BUILD THE BOOTLOADER + KERNEL                          ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

if /i not exist ".\build\bin" mkdir "build\bin"
"%FASM%" ".\source\boot\stage1.asm" ".\build\bin\stage1.bin"
"%FASM%" ".\source\boot\stage2.asm" ".\build\bin\stage2.bin"
"%FASM%" ".\source\kernel32.asm"    ".\build\bin\kernel32.exe"

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: MAKE FLOPPY IMAGE                                      ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

xcopy "%BFI%" "."
xcopy ".\build\bin\kernel32.exe" "."
xcopy ".\build\bin\stage1.bin" "."
xcopy ".\build\bin\stage2.bin" "."
BFI.EXE -t=144 -0=KERNEL32.EXE -l=VEDIA -b=STAGE1.BIN -f=VEDIA32.IMG ".\build\bin"
rem remove the BFI file
del /q "BFI.EXE"

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: PLACE GENERATED IMAGE IN "\image" DIRECTORY            ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

if /i not exist ".\build\img" mkdir "build\img"
xcopy "quore32.img" ".\build\img" /Q

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: DISPLAY THE BUILD INFORMATION                          ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

echo.
echo.
time /t > time.txt
set /p time=<time.txt
del /q time.txt
echo Completed Build on %DATE% at %time%
pause>nul
exit